home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8252 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: news.magicnet.net!usenet
  2. From: gamecox@magicnet.net (Jody Hagins)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Pointer to members
  5. Date: Fri, 16 Feb 1996 09:17:21 GMT
  6. Organization: MagicNet, Inc.
  7. Message-ID: <4g17fj$rhf@comet.magicnet.net>
  8. References: <4fqg56$cfl@gina.zfn.uni-bremen.de>
  9. NNTP-Posting-Host: pm5-10.magicnet.net
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. j03k@alf.zfn.uni-bremen.de (Holger Burde) wrote:
  13.  
  14. >Hi,
  15.  
  16. >I am writing a drawing Application with C++ and the Motif Toolkit.
  17. >I saw that the 'right' way to use Classmembers as callbackproc's is
  18. >to declare them static (static members have ordinary Functions Pointers).
  19.  
  20. >Is this the only way ?????
  21.  
  22. >Is there any way to get normal member fuctions accepted (cast  from
  23. >member function to Functions Pointer without compiler feature ...) ??
  24.  
  25.  
  26. >I tried some (stupid?) casting  but nothing worked (not accepted or
  27. >crashed when called ...(:- ).
  28.  
  29. >thanx in advance
  30.  
  31. >hb
  32.  
  33.  
  34. The reason you need static functions is that a non-static C++ member
  35. expects a pointer to the object as the first parameter to the
  36. function.  There may be room in implementations to allow this pointer
  37. be some other parameter than the first, but I've not seen it.
  38.  
  39. I've used several different ways to implement callbacks such as this
  40. with C++.  Probably the most useful was to use a callback class.
  41.  
  42. If you want more specific info, on callback classes, email me at
  43. wjh@ssc.siemens.com or gamecox@magicnet.net
  44.  
  45.     -Jody
  46.  
  47.  
  48.